package cn.wsalix.type;

public enum GenderEnum {
	unknown("0", "保密"), male("1", "男"), female("2", "女");
	private String code;
	private String title;

	GenderEnum(String code, String title) {
		this.code = code;
		this.title = title;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public static GenderEnum findByCode(String code) {
		if (code == null || code.equals("")) {
			return unknown;
		}
		for (GenderEnum obj : GenderEnum.values()) {
			if (obj.getCode().equals(code)) {
				return obj;
			}
		}
		return null;
	}

	public static GenderEnum findByTitle(String title) {
		for (GenderEnum obj : GenderEnum.values()) {
			if (obj.getTitle().equals(title)) {
				return obj;
			}
		}
		return unknown;
	}
}
